const { post, get } = require("../utils/request")

function getAccessToken(appid, secret) {
  console.log(appid)
  return get(`https://developer.toutiao.com/api/apps/token?grant_type=client_credential&appid=${appid}&secret=${secret}`)
}

function createQRCode(access_token, data) {
  return post(`https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=${access_token}`, data)
}

function getCode2Session(appid, secret, code) {
  // console.log(`https://developer.toutiao.com/api/apps/jscode2session?appid=${appid}&code=${code}&secret=${secret}`)
  return get(`https://developer.toutiao.com/api/apps/jscode2session?appid=${appid}&code=${code}&secret=${secret}`)
}
module.exports = {
  getAccessToken,
  createQRCode,
  getCode2Session
}